package com.cksys.achievement.config.login.qq;

import com.cksys.achievement.exception.NoBindingException;
import com.cksys.achievement.exception.ValidateCodeException;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @ClassName: QQAuthenticationSuccessHandler
 * @author: zyx
 * @E-mail: 1377631190@qq.com
 * @DATE: 2020/4/16 17:31
 */
public class QQAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        String result = "{\"payload\":\"%s\",\"success\":true,\"msg\":\"%s\",\"code\":200}";
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = response.getWriter();
        result = String.format(result, "登录成功", "登录成功");
        out.write(result);
        out.flush();
        out.close();
    }
}
